var ajaxHelper = require("../../utils/ajaxhelp");
let serviceUrl = getApp().globalData.serviceUrl;
let token = wx.getStorageSync('token');

const getScreenAllPage = (pageNum, pageSize,) => {
	serviceUrl = getApp().globalData.serviceUrl;
	token = wx.getStorageSync('token');
	return ajaxHelper.promiseRequst(serviceUrl + "/api/Screen/GetScreenByDomainNamePaging1", {
		'Authorization': 'Bearer ' + token
	}, "GET", {
		pageNum: pageNum,
		pageSize: pageSize
	})
}

const getScreenStatusPage = (pageNum, pageSize, state) => {
	serviceUrl = getApp().globalData.serviceUrl;
	token = wx.getStorageSync('token');
	return ajaxHelper.promiseRequst(serviceUrl + "/api/Screen/GetScreenByDomainNameAndStatePaging1", {
		'Authorization': 'Bearer ' + token
	}, "GET", {
		pageNum: pageNum,
		pageSize: pageSize,
		scState: state
	})
}

const GetScreenItemData = (leadId) => {
	serviceUrl = getApp().globalData.serviceUrl;
	token = wx.getStorageSync('token');
	return ajaxHelper.promiseRequst(serviceUrl + "/api/Screen/GetScreenItemData", {
		'Authorization': 'Bearer ' + token
	}, "GET", {
		leadId:leadId
	})
}

const CreateScreenData = (screenData) => {
	serviceUrl = getApp().globalData.serviceUrl;
	token = wx.getStorageSync('token');
	return ajaxHelper.promiseRequst(serviceUrl + "/api/Screen/CreateScreenData", {
		'Authorization': 'Bearer ' + token
	}, "POST", screenData)
}


const GetScreenByScreenID = (screenId) => {
	serviceUrl = getApp().globalData.serviceUrl;
	token = wx.getStorageSync('token');
	return ajaxHelper.promiseRequst(serviceUrl + "/api/Screen/GetScreenByScreenID", {
		'Authorization': 'Bearer ' + token
	}, "GET", {
		screenId:screenId
	})
}

const UpdateScreenData = (screen) => {
	serviceUrl = getApp().globalData.serviceUrl;
	token = wx.getStorageSync('token');
	return ajaxHelper.promiseRequst(serviceUrl + "/api/Screen/UpdateScreenData", {
		'Authorization': 'Bearer ' + token
	}, "POST", screen)
}


const CreateSQXXCJ = (sqsc) => {
	serviceUrl = getApp().globalData.serviceUrl;
	token = wx.getStorageSync('token');
	return ajaxHelper.promiseRequst(serviceUrl + "/api/Screen/CreateSQXXCJ", {
		'Authorization': 'Bearer ' + token
	}, "POST",sqsc )
}

const CheckIn = (screen) => {
	serviceUrl = getApp().globalData.serviceUrl;
	token = wx.getStorageSync('token');
	return ajaxHelper.promiseRequst(serviceUrl + "/api/Screen/CheckIn", {
		'Authorization': 'Bearer ' + token
	}, "POST", screen)
}

const QryScreenStatisticsBy = (screenteamid,startDate,endDate) => {
	serviceUrl = getApp().globalData.serviceUrl;
	token = wx.getStorageSync('token');
	return ajaxHelper.promiseRequst(serviceUrl + "/api/Screen/QryScreenStatisticsBy", {
		'Authorization': 'Bearer ' + token
	}, "GET", {
		screenteamid: screenteamid,
		startDate: startDate,
		endDate: endDate
	})
}

const GetScreenTeamMemberByTeamid = (teamid) => {
	serviceUrl = getApp().globalData.serviceUrl;
	token = wx.getStorageSync('token');
	return ajaxHelper.promiseRequst(serviceUrl + "/api/ScreenTeam/GetScreenTeamMemberByTeamid", {
		'Authorization': 'Bearer ' + token
	}, "GET", {teamid:teamid})
}

const QueryAllEquipment = () => {
	serviceUrl = getApp().globalData.serviceUrl;
	token = wx.getStorageSync('token');
	return ajaxHelper.promiseRequst(serviceUrl + "/api/Screen/QueryAllEquipment", {
		'Authorization': 'Bearer ' + token
	}, "GET", {})
}


module.exports = {
	getScreenAllPage,
	getScreenStatusPage,
	GetScreenItemData,
	CreateScreenData,
	GetScreenByScreenID,
	UpdateScreenData,
	CreateSQXXCJ,
	CheckIn,
	QryScreenStatisticsBy,
	GetScreenTeamMemberByTeamid,
	QueryAllEquipment,
}